package com.xc.quickstart.common.bean;

import com.xc.quickstart.common.event.SampleApplicationEvent;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;

/**
 * @Author: yinyansheng
 * @Date: 2019/9/3 0003
 */
@Component
public class SamplePublisher {

    private final ApplicationContext applicationContext;

    @Autowired
    public SamplePublisher(ApplicationContext applicationContext) {
        this.applicationContext = applicationContext;
    }

    @Async
    public void publish(Integer bizId, String content) {
        applicationContext.publishEvent(new SampleApplicationEvent(this,
                Long.valueOf(bizId),
                content));
    }

}
